<!--!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Activanet</title>
        <link rel="stylesheet" href="<?=base_url();?>jquery_ui/css/blitzer/jquery-ui-1.9.0.custom.css"/>
        <script src="<?=base_url();?>jquery_ui/js/jquery-1.8.2.js"></script>
        <script src="<?=base_url();?>jquery_ui/js/jquery-ui-1.9.1.custom.js"></script>
        <script src="<?=base_url();?>jquery_ui/js/jquery-ui-1.9.1.custom.min.js"></script-->
        
        <script type="text/javascript">
            $(document).ready(
            function(){
                base_url = '<?=base_url();?>index.php/';
                $("#login").hide();
                $.post(base_url+"welcome/verificaLogin",{}, 
                function(data){
                    if(data.msje=='true') //Está logeado!
                    {
                        $("#login").hide();
                        $.ajax({
                            url: base_url+'welcome/cargaRegistro',
                            cache:false,
                            success:function(htmlresponse,data){
                                $("#registro").html(htmlresponse,data);
                                $("#registro").show();
                            }
                        });
                    }
                    else
                    {
                        $("#registro").hide();
                        $("#login").show();
                    }
                },'json');
                $("#btn1").button().click(
                function(){    
                    $.post(
                        base_url+'welcome/Login',
                        {nickname:$("#usuario").val(),clave:$("#clave").val()},
                        function(data){
                            if(data.msj=="false")
                            {
                                $("#msj").html("<p>Usuario no registrado!</p>");
                                $("#msj").show("fast");
                            }
                            else{
                                $("#login").hide('fast');
                                $.ajax({
                                    url: base_url+'welcome/cargaPrincipal',
                                    cache:false,
                                    success:function(htmlresponse,data){
                                        $(document).html(htmlresponse,data);
                                        //$("#registro").show('slow');  
                                    }
                                });
                            }
                        },"json"
                    );
                });
            });
        </script>
        <div id="login" style="display:block;">
            <div id="entradas">
                <input class="uno" id="usuario" type="text" size="25"/>
                <input class="uno" id="clave" type="password" size="25"/>
            </div>
            <div id="msj" style="display:none;"></div>
            <a id="reg" href="<?=base_url();?>index.php/welcome/registrar">Registrar</a>
            <button id="btn1">Conectar</button>
        </div>